1 module geany_d_binding.geany.plugins; 2 3 import geany_d_binding.geany.types; 4 import geany_d_binding.geany.plugindata: GEANY_API_VERSION, GEANY_ABI_VERSION; 5 import gtkc.gobjecttypes: GCallback; 6 import gtkc.gtktypes: GtkDialog, GtkWidget, GDestroyNotify; 7 import glib.c.types: GModule; 8 9 extern(System) @nogc nothrow 10 { 11 /** Basic information about a plugin available to Geany without loading the plugin. */ 12 struct PluginInfo 13 { 14 /** The name of the plugin. */ 15 const(gchar)* name; 16 /** The description of the plugin. */ 17 const(gchar)* description; 18 /** The version of the plugin. */ 19 const(gchar)* _version; 20 /** The author of the plugin. */ 21 const(gchar)* author; 22 } 23 24 import geany_d_binding.geany.plugindata: GeanyData; 25 26 /** Basic information for the plugin and identification. */ 27 struct GeanyPlugin 28 { 29 PluginInfo* info; /**< Fields set in plugin_set_info(). */ 30 GeanyData* geany_data; /**< Pointer to global GeanyData intance */ 31 GeanyPluginFuncs* funcs; /**< Functions implemented by the plugin, set in geany_load_module() */ 32 GeanyProxyFuncs* proxy_funcs; /**< Hooks implemented by the plugin if it wants to act as a proxy 33 Must be set prior to calling geany_plugin_register_proxy() */ 34 private GeanyPluginPrivate* priv; /* private */ 35 } 36 37 /** Callback functions that need to be implemented for every plugin. */ 38 struct GeanyPluginFuncs 39 { 40 /** Array of plugin-provided signal handlers @see PluginCallback */ 41 PluginCallback* callbacks; 42 /** Called to initialize the plugin, when the user activates it (must not be @c NULL) */ 43 gboolean function(GeanyPlugin* plugin, gpointer pdata) _init; 44 /** plugins configure dialog, optional (can be @c NULL) */ 45 GtkWidget* function(GeanyPlugin* plugin, GtkDialog* dialog, gpointer pdata) configure; 46 /** Called when the plugin should show some help, optional (can be @c NULL) */ 47 void function(GeanyPlugin* plugin, gpointer pdata) help; 48 /** Called when the plugin is disabled or when Geany exits (must not be @c NULL) */ 49 void function(GeanyPlugin* p, gpointer pdata) cleanup; 50 } 51 52 /** Callback array entry type used with the @ref plugin_callbacks symbol. */ 53 struct PluginCallback 54 { 55 /** The name of signal, must be an existing signal. For a list of available signals, 56 * please see the @link pluginsignals.c Signal documentation @endlink. */ 57 const(gchar)* signal_name; 58 /** A callback function which is called when the signal is emitted. */ 59 GCallback callback; 60 /** Set to TRUE to connect your handler with g_signal_connect_after(). */ 61 gboolean after; 62 /** The user data passed to the signal handler. If set to NULL then the signal 63 * handler will receive the data set with geany_plugin_register_full() or 64 * geany_plugin_set_data() */ 65 gpointer user_data; 66 } 67 68 struct GeanyProxyFuncs; 69 struct GeanyPluginPrivate; 70 71 gboolean geany_plugin_register(GeanyPlugin* plugin, gint api_version, 72 gint min_api_version, gint abi_version); 73 74 gboolean geany_plugin_register_full(GeanyPlugin* plugin, gint api_version, 75 gint min_api_version, gint abi_version, 76 gpointer data, GDestroyNotify free_func); 77 } 78 79 extern(System) export const(gchar)* g_module_check_init(GModule* modul) 80 { 81 import core.runtime: Runtime; 82 83 Runtime.initialize(); //TODO: result check 84 85 return null; 86 } 87 88 extern(System) export void g_module_unload(GModule* modul) 89 { 90 import core.runtime: Runtime; 91 92 Runtime.terminate(); //TODO: result check 93 } 94 95 /// It is need to implement it in the plugin code 96 extern(System) export void geany_load_module(GeanyPlugin *plugin) nothrow; 97 98 gboolean GEANY_PLUGIN_REGISTER(GeanyPlugin* plugin, gint min_api_version) 99 { 100 return geany_plugin_register(plugin, GEANY_API_VERSION, min_api_version, GEANY_ABI_VERSION); 101 } 102 103 gboolean GEANY_PLUGIN_REGISTER_FULL(GeanyPlugin* plugin, gint min_api_version, gpointer pdata, GDestroyNotify free_func) 104 { 105 return geany_plugin_register_full(plugin, GEANY_API_VERSION, min_api_version, GEANY_ABI_VERSION, pdata, free_func); 106 }